import { TreeSelect } from "antd";
import React, { useState, useImperativeHandle } from "react";
import Notfound from "../notFound/not-found";
const XxtreeSelect = (props) => {

    const { treeData, fieldNames, defaultValue, placeholder = "", allowClear = false } = props
    const [treeLine, setTreeLine] = useState(true);
    const [showLeafIcon, setShowLeafIcon] = useState(false);

    const [val, setVal] = useState(null)
    const onchangeVal = () => {
        console.log(val)
    }
    return (
        <>
            <TreeSelect
                fieldNames={fieldNames}
                showSearch
                treeLine={
                    treeLine && {
                        showLeafIcon,
                    }
                }
                style={{
                    width: '100%',
                    flex: 1
                }}
                dropdownStyle={{
                    maxHeight: 400,
                    overflow: 'auto',
                }}
                
                placeholder={placeholder}
                allowClear={allowClear}
                treeDefaultExpandAll
                notFoundContent={<Notfound />}
                treeData={treeData}
                defaultValue={defaultValue}//传入当前默认值
                // treeNodeFilterProp="comSName"
                filterTreeNode={ //默认允许输入过滤
                    (string, treeNode) => {
                        if (treeNode[fieldNames.label].indexOf(string) > -1) {
                            return true;
                        }
                        if (treeNode[fieldNames.value].indexOf(string) > -1) {
                            return true;
                        }
                    }
                }
                {...props}
               

            />
        </>
    )

}

export default XxtreeSelect;